package com.cc.servlet;

import com.cc.entity.MeetingRoom;
import com.cc.service.Impl.MeetingRoomServiceImpl;
import com.cc.service.MeetingRoomService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.io.IOException;
import java.util.List;

@WebServlet("/meetingRoom.do")
public class MeetingRoomServlet extends HttpServlet {
    //获取数据在Service中拿数据
    private MeetingRoomService meetingRoomService = new MeetingRoomServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    //在doPost中写代码
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String method = req.getParameter("method") == null ? "list" : req.getParameter("method") == null ? "add" : req.getParameter("method");
        switch (method) {
            case "list":
                break;
                default:
                    break;
        }
    }

    protected void doList(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<MeetingRoom> meetingRoom = meetingRoomService.queryMeetingRoom();
        req.setAttribute("meetingRoom", meetingRoom);
        req.getRequestDispatcher("meetingRoom.do").forward(req, resp);
    }
}